//
//  Dictionary+Extension.swift
//  MYDoctor
//
//  Created by Denny on 2024/4/17.
//

import UIKit

extension Dictionary {
     func toJsonString() -> String {
        var result:String = ""
        do {
          //如果设置options为JSONSerialization.WritingOptions.prettyPrinted，则打印格式更好阅读
          let jsonData = try JSONSerialization.data(withJSONObject: self, options: JSONSerialization.WritingOptions.init(rawValue: 0))
       
          if let JSONString = String(data: jsonData, encoding: String.Encoding.utf8) {
            result = JSONString
          }
       
        } catch {
          result = ""
        }
        return result
      }
}
